<html>
<head><meta charset="utf-8"><title>Reverting mut + default match bindings · edition 2021 · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/268952-edition-2021/index.html">edition 2021</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/268952-edition-2021/topic/Reverting.20mut.20.2B.20default.20match.20bindings.html">Reverting mut + default match bindings</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="226183678"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/268952-edition%202021/topic/Reverting%20mut%20%2B%20default%20match%20bindings/near/226183678" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> CryZe <a href="https://rust-lang.github.io/zulip_archive/stream/268952-edition-2021/topic/Reverting.20mut.20.2B.20default.20match.20bindings.html#226183678">(Feb 12 2021 at 19:25)</a>:</h4>
<p>Rust 2018 stabilized default match bindings. <a href="https://github.com/rust-lang/rfcs/blob/491e0af/text/2005-match-ergonomics.md">https://github.com/rust-lang/rfcs/blob/491e0af/text/2005-match-ergonomics.md</a><br>
The RFC specifies that the default binding mode can only ever become a reference, it can never be reset: <a href="https://github.com/rust-lang/rfcs/blob/491e0af/text/2005-match-ergonomics.md#binding-mode-rules">https://github.com/rust-lang/rfcs/blob/491e0af/text/2005-match-ergonomics.md#binding-mode-rules</a></p>
<p>Quoting the RFC:</p>
<blockquote>
<p>Note that there is no exit from the ref binding mode.</p>
</blockquote>
<p>Quoting Niko:</p>
<blockquote>
<p>In particular, once we are in ref mode, we never leave.</p>
</blockquote>
<p>However after the implementation got stabilized, people eventually started realizing that the implementation does not match the RFC. In particular using the mut keyword accidentally resets the default binding mode.</p>
<p>The following thread starting with this comment: <a href="https://github.com/rust-lang/rust/issues/64586#issuecomment-599823971">https://github.com/rust-lang/rust/issues/64586#issuecomment-599823971</a></p>
<p>They consider it a mistake as well and suggest that this can either be reverted in Rust 2018 via a crater run and hoping no one relies on the bug yet or via Rust 2021. The crater run did apparently not happen, and since we are close to Rust 2021, this should be considered for inclusion in the edition.</p>
<p>(unfortunately I couldn't find all the sources again, but this should give a decent picture of the situation)</p>



<a name="226379849"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/268952-edition%202021/topic/Reverting%20mut%20%2B%20default%20match%20bindings/near/226379849" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/268952-edition-2021/topic/Reverting.20mut.20.2B.20default.20match.20bindings.html#226379849">(Feb 15 2021 at 12:50)</a>:</h4>
<p>Hmmmmmm</p>



<a name="226398507"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/268952-edition%202021/topic/Reverting%20mut%20%2B%20default%20match%20bindings/near/226398507" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/268952-edition-2021/topic/Reverting.20mut.20.2B.20default.20match.20bindings.html#226398507">(Feb 15 2021 at 15:41)</a>:</h4>
<p>I feel like we can deprecate this at any point and we're not in a hurry to make it a hard error</p>



<a name="226398519"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/268952-edition%202021/topic/Reverting%20mut%20%2B%20default%20match%20bindings/near/226398519" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/268952-edition-2021/topic/Reverting.20mut.20.2B.20default.20match.20bindings.html#226398519">(Feb 15 2021 at 15:41)</a>:</h4>
<p>Is there a plan to repurpose the syntax, somehow?</p>



<a name="226516979"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/268952-edition%202021/topic/Reverting%20mut%20%2B%20default%20match%20bindings/near/226516979" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> varkor <a href="https://rust-lang.github.io/zulip_archive/stream/268952-edition-2021/topic/Reverting.20mut.20.2B.20default.20match.20bindings.html#226516979">(Feb 16 2021 at 14:12)</a>:</h4>
<p>To be honest, I hadn't seriously considered this might be changed, because it would break existing <code>match</code> expressions. However, the current default match bindings is a real pain. It does seem plausible that "fixing" existing <code>match</code> expressions could be automated by rustfix.</p>



<a name="226517123"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/268952-edition%202021/topic/Reverting%20mut%20%2B%20default%20match%20bindings/near/226517123" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> varkor <a href="https://rust-lang.github.io/zulip_archive/stream/268952-edition-2021/topic/Reverting.20mut.20.2B.20default.20match.20bindings.html#226517123">(Feb 16 2021 at 14:12)</a>:</h4>
<p><span class="user-mention silent" data-user-id="116009">nikomatsakis</span> <a href="#narrow/stream/268952-edition/topic/Reverting.20mut.20.2B.20default.20match.20bindings/near/226398519">said</a>:</p>
<blockquote>
<p>Is there a plan to repurpose the syntax, somehow?</p>
</blockquote>
<p>Arguably the reason to make the existing syntax invalid <em>would be</em> to repurpose the way default match bindings work.</p>



<a name="226517350"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/268952-edition%202021/topic/Reverting%20mut%20%2B%20default%20match%20bindings/near/226517350" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> varkor <a href="https://rust-lang.github.io/zulip_archive/stream/268952-edition-2021/topic/Reverting.20mut.20.2B.20default.20match.20bindings.html#226517350">(Feb 16 2021 at 14:14)</a>:</h4>
<blockquote>
<p>The crater run did apparently not happen, and since we are close to Rust 2021, this should be considered for inclusion in the edition.</p>
</blockquote>
<p>A crater run would maybe give a better estimate of the extent of breakage, but I don't see that there's any chance this isn't relied upon by <em>some</em> code. It's too easy to write not to be.</p>



<a name="226517607"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/268952-edition%202021/topic/Reverting%20mut%20%2B%20default%20match%20bindings/near/226517607" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> varkor <a href="https://rust-lang.github.io/zulip_archive/stream/268952-edition-2021/topic/Reverting.20mut.20.2B.20default.20match.20bindings.html#226517607">(Feb 16 2021 at 14:16)</a>:</h4>
<p>My understand is that we would have to make an explicit decision to change the behaviour of default match bindings. (From a procedural point of view, I think something went wrong with DMB in that this issue was not noticed before stabilisation, but one would have to look back at the discussion more closely to figure out how it could have been avoided.)</p>



<a name="226517911"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/268952-edition%202021/topic/Reverting%20mut%20%2B%20default%20match%20bindings/near/226517911" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> varkor <a href="https://rust-lang.github.io/zulip_archive/stream/268952-edition-2021/topic/Reverting.20mut.20.2B.20default.20match.20bindings.html#226517911">(Feb 16 2021 at 14:19)</a>:</h4>
<p>I do think it would be fairly straightforward to modify the implementation of DMB in the presence of a compiler flag that would allow us to experiment with it.</p>



<a name="226518054"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/268952-edition%202021/topic/Reverting%20mut%20%2B%20default%20match%20bindings/near/226518054" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> varkor <a href="https://rust-lang.github.io/zulip_archive/stream/268952-edition-2021/topic/Reverting.20mut.20.2B.20default.20match.20bindings.html#226518054">(Feb 16 2021 at 14:20)</a>:</h4>
<p>I would be happy to be involved with this in some capacity, though I don't have time at the moment to do the implementation.</p>



<a name="226712591"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/268952-edition%202021/topic/Reverting%20mut%20%2B%20default%20match%20bindings/near/226712591" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/268952-edition-2021/topic/Reverting.20mut.20.2B.20default.20match.20bindings.html#226712591">(Feb 17 2021 at 19:31)</a>:</h4>
<p><span class="user-mention" data-user-id="121053">@varkor</span> I don't really understand what you're suggesting here</p>



<a name="226712681"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/268952-edition%202021/topic/Reverting%20mut%20%2B%20default%20match%20bindings/near/226712681" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/268952-edition-2021/topic/Reverting.20mut.20.2B.20default.20match.20bindings.html#226712681">(Feb 17 2021 at 19:32)</a>:</h4>
<p>but let me read the comment, first of all</p>



<a name="226712727"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/268952-edition%202021/topic/Reverting%20mut%20%2B%20default%20match%20bindings/near/226712727" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/268952-edition-2021/topic/Reverting.20mut.20.2B.20default.20match.20bindings.html#226712727">(Feb 17 2021 at 19:33)</a>:</h4>
<p>it seems like we should just start by adding a lint against this that applies independent of edition</p>



<a name="226828354"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/268952-edition%202021/topic/Reverting%20mut%20%2B%20default%20match%20bindings/near/226828354" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> varkor <a href="https://rust-lang.github.io/zulip_archive/stream/268952-edition-2021/topic/Reverting.20mut.20.2B.20default.20match.20bindings.html#226828354">(Feb 18 2021 at 15:36)</a>:</h4>
<p><span class="user-mention silent" data-user-id="116009">nikomatsakis</span> <a href="#narrow/stream/268952-edition/topic/Reverting.20mut.20.2B.20default.20match.20bindings/near/226712591">said</a>:</p>
<blockquote>
<p><span class="user-mention silent" data-user-id="121053">varkor</span> I don't really understand what you're suggesting here</p>
</blockquote>
<p>Let me just summarise the issue for anyone reading along. Consider the following:</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="k">struct</span> <span class="nc">S</span><span class="p">(</span><span class="kt">u32</span><span class="p">);</span><span class="w"></span>

<span class="k">fn</span> <span class="nf">foo</span><span class="p">(</span><span class="n">x</span>: <span class="kp">&amp;</span><span class="nc">S</span><span class="p">)</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="kd">let</span><span class="w"> </span><span class="n">_</span>: <span class="kp">&amp;</span><span class="kt">u32</span> <span class="o">=</span><span class="w"> </span><span class="k">match</span><span class="w"> </span><span class="n">x</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">        </span><span class="n">S</span><span class="p">(</span><span class="n">y</span><span class="p">)</span><span class="w"> </span><span class="o">=&gt;</span><span class="w"> </span><span class="n">y</span><span class="p">,</span><span class="w"></span>
<span class="w">        </span><span class="n">_</span><span class="w"> </span><span class="o">=&gt;</span><span class="w"> </span><span class="o">&amp;</span><span class="mi">0</span><span class="p">,</span><span class="w"></span>
<span class="w">    </span><span class="p">};</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>
<p>The type of <code>y</code> inside the match arm pattern is <code>u32</code>, whereas in the arm expression it is <code>&amp;u32</code>. This is really confusing: it essentially means the reference wrapping happens "after" matching, rather than "during". This leads to counterintuitive obstructions, such as the following not being allowed:</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="k">fn</span> <span class="nf">foo</span><span class="p">(</span><span class="n">x</span>: <span class="kp">&amp;</span><span class="nc">S</span><span class="p">)</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="kd">let</span><span class="w"> </span><span class="n">_</span>: <span class="kt">u32</span> <span class="o">=</span><span class="w"> </span><span class="k">match</span><span class="w"> </span><span class="n">x</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">        </span><span class="n">S</span><span class="p">(</span><span class="o">&amp;</span><span class="n">y</span><span class="p">)</span><span class="w"> </span><span class="o">=&gt;</span><span class="w"> </span><span class="n">y</span><span class="p">,</span><span class="w"></span>
<span class="w">        </span><span class="n">_</span><span class="w"> </span><span class="o">=&gt;</span><span class="w"> </span><span class="mi">0</span><span class="p">,</span><span class="w"></span>
<span class="w">    </span><span class="p">};</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>
<p>because inside the pattern, <code>y</code> isn't a reference type, so can't be dereferenced.</p>



<a name="226828459"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/268952-edition%202021/topic/Reverting%20mut%20%2B%20default%20match%20bindings/near/226828459" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/268952-edition-2021/topic/Reverting.20mut.20.2B.20default.20match.20bindings.html#226828459">(Feb 18 2021 at 15:37)</a>:</h4>
<p>Yeah that seems painful</p>



<a name="226828486"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/268952-edition%202021/topic/Reverting%20mut%20%2B%20default%20match%20bindings/near/226828486" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> varkor <a href="https://rust-lang.github.io/zulip_archive/stream/268952-edition-2021/topic/Reverting.20mut.20.2B.20default.20match.20bindings.html#226828486">(Feb 18 2021 at 15:37)</a>:</h4>
<p>My original proposal was to change the behaviour of DMB so that <code>y</code> is a reference type inside the pattern (the "during" method).</p>



<a name="226828527"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/268952-edition%202021/topic/Reverting%20mut%20%2B%20default%20match%20bindings/near/226828527" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> varkor <a href="https://rust-lang.github.io/zulip_archive/stream/268952-edition-2021/topic/Reverting.20mut.20.2B.20default.20match.20bindings.html#226828527">(Feb 18 2021 at 15:37)</a>:</h4>
<p>It seems on the face of it like this is just lifting a restriction, so was possibly backwards compatible.</p>



<a name="226828781"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/268952-edition%202021/topic/Reverting%20mut%20%2B%20default%20match%20bindings/near/226828781" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> varkor <a href="https://rust-lang.github.io/zulip_archive/stream/268952-edition-2021/topic/Reverting.20mut.20.2B.20default.20match.20bindings.html#226828781">(Feb 18 2021 at 15:39)</a>:</h4>
<p>However, it turns out that <code>mut</code> resets the binding mode, so that it's not backwards compatible:</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="k">fn</span> <span class="nf">foo</span><span class="p">(</span><span class="n">x</span>: <span class="kp">&amp;</span><span class="nc">S</span><span class="p">)</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="kd">let</span><span class="w"> </span><span class="n">_</span>: <span class="kt">u32</span> <span class="o">=</span><span class="w"> </span><span class="k">match</span><span class="w"> </span><span class="n">x</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">        </span><span class="n">S</span><span class="p">(</span><span class="k">mut</span><span class="w"> </span><span class="n">y</span><span class="p">)</span><span class="w"> </span><span class="o">=&gt;</span><span class="w"> </span><span class="n">y</span><span class="p">,</span><span class="w"></span>
<span class="w">        </span><span class="n">_</span><span class="w"> </span><span class="o">=&gt;</span><span class="w"> </span><span class="mi">0</span><span class="p">,</span><span class="w"></span>
<span class="w">    </span><span class="p">};</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>
<p>This currently compiles, but under my proposed match binding behaviour, it would not, because <code>y</code> should have type <code>&amp;u32</code> (but currently Rust thinks it has type <code>u32</code>).</p>



<a name="226828834"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/268952-edition%202021/topic/Reverting%20mut%20%2B%20default%20match%20bindings/near/226828834" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> varkor <a href="https://rust-lang.github.io/zulip_archive/stream/268952-edition-2021/topic/Reverting.20mut.20.2B.20default.20match.20bindings.html#226828834">(Feb 18 2021 at 15:39)</a>:</h4>
<p>To clarify, <strong>depending on whether or not you have <code>mut</code> in front of the variable changes whether or not <code>y</code> has reference type</strong>.</p>



<a name="226828959"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/268952-edition%202021/topic/Reverting%20mut%20%2B%20default%20match%20bindings/near/226828959" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> varkor <a href="https://rust-lang.github.io/zulip_archive/stream/268952-edition-2021/topic/Reverting.20mut.20.2B.20default.20match.20bindings.html#226828959">(Feb 18 2021 at 15:40)</a>:</h4>
<p>This seems entirely broken; I imagine it was just totally overlooked during implementation and stabilisation.</p>



<a name="226829129"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/268952-edition%202021/topic/Reverting%20mut%20%2B%20default%20match%20bindings/near/226829129" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> varkor <a href="https://rust-lang.github.io/zulip_archive/stream/268952-edition-2021/topic/Reverting.20mut.20.2B.20default.20match.20bindings.html#226829129">(Feb 18 2021 at 15:41)</a>:</h4>
<p>I personally feel that changing the behaviour of DMB (to "during") would be a huge improvement. However, it would break some code (those matching on reference types and using <code>mut</code>; possibly some others, but this is the only one we spotted so far).</p>



<a name="226829300"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/268952-edition%202021/topic/Reverting%20mut%20%2B%20default%20match%20bindings/near/226829300" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> varkor <a href="https://rust-lang.github.io/zulip_archive/stream/268952-edition-2021/topic/Reverting.20mut.20.2B.20default.20match.20bindings.html#226829300">(Feb 18 2021 at 15:42)</a>:</h4>
<p>I imagine the new implementation would not be very difficult, especially for someone somewhat familiar with how DMB works at the moment. We could implement it, see what code break under this new behaviour, and take it from there.</p>



<a name="226829469"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/268952-edition%202021/topic/Reverting%20mut%20%2B%20default%20match%20bindings/near/226829469" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> varkor <a href="https://rust-lang.github.io/zulip_archive/stream/268952-edition-2021/topic/Reverting.20mut.20.2B.20default.20match.20bindings.html#226829469">(Feb 18 2021 at 15:43)</a>:</h4>
<p><span class="user-mention silent" data-user-id="116009">nikomatsakis</span> <a href="#narrow/stream/268952-edition/topic/Reverting.20mut.20.2B.20default.20match.20bindings/near/226712727">said</a>:</p>
<blockquote>
<p>it seems like we should just start by adding a lint against this that applies independent of edition</p>
</blockquote>
<p>This might be difficult to do usefully: the code that works at the moment will break under the new behaviour, and vice versa. Any time you match on a reference and use <code>mut</code>.</p>



<a name="226829748"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/268952-edition%202021/topic/Reverting%20mut%20%2B%20default%20match%20bindings/near/226829748" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> varkor <a href="https://rust-lang.github.io/zulip_archive/stream/268952-edition-2021/topic/Reverting.20mut.20.2B.20default.20match.20bindings.html#226829748">(Feb 18 2021 at 15:45)</a>:</h4>
<p>So I'm not sure there's much a helpful message we could output, because there may not be a valid suggestion we can make.</p>



<a name="226829817"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/268952-edition%202021/topic/Reverting%20mut%20%2B%20default%20match%20bindings/near/226829817" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> varkor <a href="https://rust-lang.github.io/zulip_archive/stream/268952-edition-2021/topic/Reverting.20mut.20.2B.20default.20match.20bindings.html#226829817">(Feb 18 2021 at 15:45)</a>:</h4>
<p>It may be that the best thing to do is to rustfix across an edition.</p>



<a name="226864779"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/268952-edition%202021/topic/Reverting%20mut%20%2B%20default%20match%20bindings/near/226864779" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Daniel Henry-Mantilla <a href="https://rust-lang.github.io/zulip_archive/stream/268952-edition-2021/topic/Reverting.20mut.20.2B.20default.20match.20bindings.html#226864779">(Feb 18 2021 at 19:19)</a>:</h4>
<p><span class="user-mention silent" data-user-id="121053">varkor</span> <a href="#narrow/stream/268952-edition/topic/Reverting.20mut.20.2B.20default.20match.20bindings/near/226829748">said</a>:</p>
<blockquote>
<p>there may not be a valid suggestion we can make</p>
</blockquote>
<p>For those using <code>mut</code> and having (on purpose or not) opted out of <code>match</code> ergonomics, the fix would be to put the necessary leading <code>&amp;</code> / <code>&amp;mut</code> in the pattern to use non-match-ergonomics syntax:</p>
<div class="codehilite" data-code-language="Diff"><pre><span></span><code>  match x {
<span class="gd">-     S(mut y) =&gt; Y,</span>
<span class="gi">+     &amp;S(mut y) =&gt; Y,</span>
      _ =&gt; 0,
  }
</code></pre></div>



<a name="226909496"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/268952-edition%202021/topic/Reverting%20mut%20%2B%20default%20match%20bindings/near/226909496" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/268952-edition-2021/topic/Reverting.20mut.20.2B.20default.20match.20bindings.html#226909496">(Feb 19 2021 at 01:31)</a>:</h4>
<p><span class="user-mention" data-user-id="121053">@varkor</span> Does using <code>ref mut</code> affect that as well? What about just <code>ref</code>?</p>



<a name="227000895"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/268952-edition%202021/topic/Reverting%20mut%20%2B%20default%20match%20bindings/near/227000895" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> varkor <a href="https://rust-lang.github.io/zulip_archive/stream/268952-edition-2021/topic/Reverting.20mut.20.2B.20default.20match.20bindings.html#227000895">(Feb 19 2021 at 17:48)</a>:</h4>
<p><span class="user-mention" data-user-id="239881">@Josh Triplett</span>: <code>ref mut</code> and <code>ref</code> work the same way as each other, i.e. <code>ref mut</code> doesn't reset the binding mode. However, <code>ref</code> still works counterintuitively in my opinion with respect to DMB. For instance, in the following:</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="k">fn</span> <span class="nf">foo</span><span class="p">(</span><span class="n">x</span>: <span class="kp">&amp;</span><span class="nc">S</span><span class="p">)</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="kd">let</span><span class="w"> </span><span class="n">_</span>: <span class="kp">&amp;</span><span class="kt">u32</span> <span class="o">=</span><span class="w"> </span><span class="k">match</span><span class="w"> </span><span class="n">x</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">        </span><span class="n">S</span><span class="p">(</span><span class="n">y</span><span class="p">)</span><span class="w"> </span><span class="o">=&gt;</span><span class="w"> </span><span class="n">y</span><span class="p">,</span><span class="w"></span>
<span class="w">        </span><span class="c1">// S(ref y) =&gt; y,</span>
<span class="w">        </span><span class="n">_</span><span class="w"> </span><span class="o">=&gt;</span><span class="w"> </span><span class="o">&amp;</span><span class="mi">0</span><span class="p">,</span><span class="w"></span>
<span class="w">    </span><span class="p">};</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>
<p>Regardless of whether the arm is <code>S(y) =&gt; y</code> or <code>S(ref y) =&gt; y</code>, the type of <code>y</code> is <code>&amp;u32</code>. I.e. <code>ref</code> has no effect whatsoever. I would instead expect <code>ref y</code> to result in <code>y: &amp;&amp;u32</code>.</p>



<a name="227012159"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/268952-edition%202021/topic/Reverting%20mut%20%2B%20default%20match%20bindings/near/227012159" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/268952-edition-2021/topic/Reverting.20mut.20.2B.20default.20match.20bindings.html#227012159">(Feb 19 2021 at 19:08)</a>:</h4>
<p>I would expect ref not to behave like match binding mode expects, because it's the alternative to binding modes.</p>



<a name="227012233"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/268952-edition%202021/topic/Reverting%20mut%20%2B%20default%20match%20bindings/near/227012233" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/268952-edition-2021/topic/Reverting.20mut.20.2B.20default.20match.20bindings.html#227012233">(Feb 19 2021 at 19:09)</a>:</h4>
<p>Binding modes make ref optional, but it makes sense that specifying it or not specifying it gives the same result.</p>



<a name="227019859"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/268952-edition%202021/topic/Reverting%20mut%20%2B%20default%20match%20bindings/near/227019859" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> varkor <a href="https://rust-lang.github.io/zulip_archive/stream/268952-edition-2021/topic/Reverting.20mut.20.2B.20default.20match.20bindings.html#227019859">(Feb 19 2021 at 19:59)</a>:</h4>
<p>I think if DBM worked as I propose, then there would be no need for an opt out.</p>



<a name="227074852"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/268952-edition%202021/topic/Reverting%20mut%20%2B%20default%20match%20bindings/near/227074852" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/268952-edition-2021/topic/Reverting.20mut.20.2B.20default.20match.20bindings.html#227074852">(Feb 20 2021 at 07:50)</a>:</h4>
<p>It's not a matter of "need". Some of us <em>want</em> an opt out.</p>



<a name="227083783"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/268952-edition%202021/topic/Reverting%20mut%20%2B%20default%20match%20bindings/near/227083783" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/268952-edition-2021/topic/Reverting.20mut.20.2B.20default.20match.20bindings.html#227083783">(Feb 20 2021 at 10:54)</a>:</h4>
<p><span class="user-mention silent" data-user-id="121053">varkor</span> <a href="#narrow/stream/268952-edition-2021/topic/Reverting.20mut.20.2B.20default.20match.20bindings/near/226829129">said</a>:</p>
<blockquote>
<p>I personally feel that changing the behaviour of DMB (to "during") would be a huge improvement.</p>
</blockquote>
<p>Agreed, this is an issue I keep running into and I haven't even found a satisfactory work-around that always works.</p>



<a name="227099580"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/268952-edition%202021/topic/Reverting%20mut%20%2B%20default%20match%20bindings/near/227099580" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> varkor <a href="https://rust-lang.github.io/zulip_archive/stream/268952-edition-2021/topic/Reverting.20mut.20.2B.20default.20match.20bindings.html#227099580">(Feb 20 2021 at 15:59)</a>:</h4>
<p><span class="user-mention silent" data-user-id="239881">Josh Triplett</span> <a href="#narrow/stream/268952-edition-2021/topic/Reverting.20mut.20.2B.20default.20match.20bindings/near/227074852">said</a>:</p>
<blockquote>
<p>It's not a matter of "need". Some of us <em>want</em> an opt out.</p>
</blockquote>
<p>Why?</p>



<a name="227099596"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/268952-edition%202021/topic/Reverting%20mut%20%2B%20default%20match%20bindings/near/227099596" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> varkor <a href="https://rust-lang.github.io/zulip_archive/stream/268952-edition-2021/topic/Reverting.20mut.20.2B.20default.20match.20bindings.html#227099596">(Feb 20 2021 at 15:59)</a>:</h4>
<p>I feel that if you want an opt-out, then the feature isn't behaving correctly.</p>



<a name="227099600"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/268952-edition%202021/topic/Reverting%20mut%20%2B%20default%20match%20bindings/near/227099600" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> varkor <a href="https://rust-lang.github.io/zulip_archive/stream/268952-edition-2021/topic/Reverting.20mut.20.2B.20default.20match.20bindings.html#227099600">(Feb 20 2021 at 15:59)</a>:</h4>
<p>That's a bug in the design.</p>



<a name="227105171"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/268952-edition%202021/topic/Reverting%20mut%20%2B%20default%20match%20bindings/near/227105171" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Daniel Henry-Mantilla <a href="https://rust-lang.github.io/zulip_archive/stream/268952-edition-2021/topic/Reverting.20mut.20.2B.20default.20match.20bindings.html#227105171">(Feb 20 2021 at 17:22)</a>:</h4>
<p><span class="user-mention silent" data-user-id="121053">varkor</span> <a href="#narrow/stream/268952-edition-2021/topic/Reverting.20mut.20.2B.20default.20match.20bindings/near/227099580">said</a>:</p>
<blockquote>
<p>Why?</p>
</blockquote>
<p>One recurrent use case is when wanting to be very explicit about the kind of accesses we lend; mainly, that of reducing <code>&amp;mut</code> borrows to a minimum; consider</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="k">match</span><span class="w"> </span><span class="o">&amp;</span><span class="k">mut</span><span class="w"> </span><span class="n">either</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="n">Either</span>::<span class="n">A</span><span class="p">(</span><span class="n">a</span><span class="p">)</span><span class="w"> </span><span class="o">=&gt;</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="cm">/* code that does not want to mutate `*a` */</span><span class="w"> </span><span class="p">},</span><span class="w"></span>
<span class="w">    </span><span class="n">Either</span>::<span class="n">B</span><span class="p">(</span><span class="n">b</span><span class="p">)</span><span class="w"> </span><span class="o">=&gt;</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="cm">/* code that may mutate `*b` */</span><span class="w"> </span><span class="p">}.</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>
<p>In cases such as this one, I like using <code>ref</code> and <code>ref mut</code> to get more control over these borrows:</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="k">match</span><span class="w"> </span><span class="n">either</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="n">Either</span>::<span class="n">A</span><span class="p">(</span><span class="k">ref</span><span class="w"> </span><span class="n">a</span><span class="p">)</span><span class="w"> </span><span class="o">=&gt;</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="cm">/* … */</span><span class="w"> </span><span class="p">},</span><span class="w"></span>
<span class="w">    </span><span class="n">Either</span>::<span class="n">B</span><span class="p">(</span><span class="k">ref</span><span class="w"> </span><span class="k">mut</span><span class="w"> </span><span class="n">b</span><span class="p">)</span><span class="w"> </span><span class="o">=&gt;</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="cm">/* … */</span><span class="w"> </span><span class="p">},</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>
<ul>
<li>This kind of difference may seem overkill, but when you are applying this kind of <code>match</code> over an <code>.iter_mut()</code>, it's quite nice to know that only the <code>B</code> variants will end up mutated <span aria-label="smile" class="emoji emoji-1f642" role="img" title="smile">:smile:</span> (real-life example: <a href="https://github.com/danielhenrymantilla/func_wrap.rs/blob/v0.1.3/src/lib.rs#L78-L90">https://github.com/danielhenrymantilla/func_wrap.rs/blob/v0.1.3/src/lib.rs#L78-L90</a>)</li>
</ul>
<p>With your proposal, we kind of can get quite close by using <code>A(ref a)</code> and <code>B(b)</code> as the patterns, except for <code>a</code> then being a <code>&amp;&amp;</code>. The full workaround with your proposal, IIUC, would be to use <code>A(&amp;(ref a))</code> (or <code>A(&amp;mut (ref a))</code>, that part is not clear to me), which is not really better (nor worse) than circumventing match ergonomics <span aria-label="shrug" class="emoji emoji-1f937" role="img" title="shrug">:shrug:</span></p>
<p>All that to say that imho, there are instances where not using match ergonomics can be a legitimate thing to do</p>
<hr>
<p>But this does not change the fact that the current situation does look like a bug / oversight, and that your proposal is definitely an improvement in that regard: one either uses match ergonomics or they don't; this "hybrid" situation <code>A(a) </code> and <code>A(ref a)</code> bind <code>a</code> the same seems bogus to me.</p>



<a name="227109469"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/268952-edition%202021/topic/Reverting%20mut%20%2B%20default%20match%20bindings/near/227109469" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/268952-edition-2021/topic/Reverting.20mut.20.2B.20default.20match.20bindings.html#227109469">(Feb 20 2021 at 18:39)</a>:</h4>
<p><span class="user-mention" data-user-id="121053">@varkor</span> Imagine, hypothetically, that we added global inference of function argument and return types, so you could omit specifying them. Then imagine asking why anyone would want to specify them, and that if you don't want to omit them, the feature must not be behaving correctly.</p>
<p>Just because the compiler can guess what I meant doesn't mean I want to let it and go along with what it guesses. The more I tell the compiler, the more it can check and cross-check my code, and the more self-documenting the code feels.</p>
<p>In any case, this is off-topic. Suffice it to say that there are reasons to want to opt out. That's separate from the question of whether those mechanisms interact properly.</p>



<a name="227114239"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/268952-edition%202021/topic/Reverting%20mut%20%2B%20default%20match%20bindings/near/227114239" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> varkor <a href="https://rust-lang.github.io/zulip_archive/stream/268952-edition-2021/topic/Reverting.20mut.20.2B.20default.20match.20bindings.html#227114239">(Feb 20 2021 at 20:02)</a>:</h4>
<p><span class="user-mention" data-user-id="232018">@Daniel Henry-Mantilla</span>: can you not dereference what you're matching on instead?</p>



<a name="227114421"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/268952-edition%202021/topic/Reverting%20mut%20%2B%20default%20match%20bindings/near/227114421" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> varkor <a href="https://rust-lang.github.io/zulip_archive/stream/268952-edition-2021/topic/Reverting.20mut.20.2B.20default.20match.20bindings.html#227114421">(Feb 20 2021 at 20:04)</a>:</h4>
<p><span class="user-mention" data-user-id="239881">@Josh Triplett</span>: I don't disagree that there's value in being explicit (though I feel this is different from "opting out"), but it doesn't seem to be that this is what <code>ref</code> with DMB is doing at the moment. However, it's probably just being distorted by the strange behaviour of DMB, so it's a peripheral discussion I agree.</p>



<a name="227114680"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/268952-edition%202021/topic/Reverting%20mut%20%2B%20default%20match%20bindings/near/227114680" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> varkor <a href="https://rust-lang.github.io/zulip_archive/stream/268952-edition-2021/topic/Reverting.20mut.20.2B.20default.20match.20bindings.html#227114680">(Feb 20 2021 at 20:08)</a>:</h4>
<p>(I would imagine that if we had type ascriptions in patterns, this would address the issue with explicitness.)</p>



<a name="227151920"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/268952-edition%202021/topic/Reverting%20mut%20%2B%20default%20match%20bindings/near/227151920" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/268952-edition-2021/topic/Reverting.20mut.20.2B.20default.20match.20bindings.html#227151920">(Feb 21 2021 at 08:11)</a>:</h4>
<p>That's an interesting though that I've never considered before!</p>



<a name="227151991"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/268952-edition%202021/topic/Reverting%20mut%20%2B%20default%20match%20bindings/near/227151991" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/268952-edition-2021/topic/Reverting.20mut.20.2B.20default.20match.20bindings.html#227151991">(Feb 21 2021 at 08:12)</a>:</h4>
<p>In the absence of historical practice and habit, I can imagine type ascription serving that purpose, yeah.</p>



<a name="227152001"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/268952-edition%202021/topic/Reverting%20mut%20%2B%20default%20match%20bindings/near/227152001" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/268952-edition-2021/topic/Reverting.20mut.20.2B.20default.20match.20bindings.html#227152001">(Feb 21 2021 at 08:12)</a>:</h4>
<p>Signposting the expected type at the point of the pattern.</p>



<a name="227156069"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/268952-edition%202021/topic/Reverting%20mut%20%2B%20default%20match%20bindings/near/227156069" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/268952-edition-2021/topic/Reverting.20mut.20.2B.20default.20match.20bindings.html#227156069">(Feb 21 2021 at 09:36)</a>:</h4>
<p>I think ascribing at least bindings in patterns would make a ton of sense.  <code>if let Ok(x: i32) = foo.parse() {</code> reads really nicely to me.</p>
<p>Previous conversation: <a href="#narrow/stream/213817-t-lang/topic/type.20ascription.20*in.20patterns*/near/213985025">https://rust-lang.zulipchat.com/#narrow/stream/213817-t-lang/topic/type.20ascription.20*in.20patterns*/near/213985025</a></p>



<a name="227204468"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/268952-edition%202021/topic/Reverting%20mut%20%2B%20default%20match%20bindings/near/227204468" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> varkor <a href="https://rust-lang.github.io/zulip_archive/stream/268952-edition-2021/topic/Reverting.20mut.20.2B.20default.20match.20bindings.html#227204468">(Feb 22 2021 at 00:09)</a>:</h4>
<p>It seems potentially worth drafting an RFC for this feature.</p>



<a name="227338476"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/268952-edition%202021/topic/Reverting%20mut%20%2B%20default%20match%20bindings/near/227338476" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/268952-edition-2021/topic/Reverting.20mut.20.2B.20default.20match.20bindings.html#227338476">(Feb 22 2021 at 21:14)</a>:</h4>
<p><span class="user-mention silent" data-user-id="121053">varkor</span> <a href="#narrow/stream/268952-edition-2021/topic/Reverting.20mut.20.2B.20default.20match.20bindings/near/226828486">said</a>:</p>
<blockquote>
<p>My original proposal was to change the behaviour of DMB so that <code>y</code> is a reference type inside the pattern (the "during" method).</p>
</blockquote>
<p>I would be potentially in favor of this at this point</p>



<a name="227338505"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/268952-edition%202021/topic/Reverting%20mut%20%2B%20default%20match%20bindings/near/227338505" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/268952-edition-2021/topic/Reverting.20mut.20.2B.20default.20match.20bindings.html#227338505">(Feb 22 2021 at 21:15)</a>:</h4>
<p>but I think this isn't the place to discuss it <em>in particular</em>, <a class="stream" data-stream-id="213817" href="/#narrow/stream/213817-t-lang">#t-lang</a> would be better, or draw up a project proposal.</p>



<a name="227338602"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/268952-edition%202021/topic/Reverting%20mut%20%2B%20default%20match%20bindings/near/227338602" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/268952-edition-2021/topic/Reverting.20mut.20.2B.20default.20match.20bindings.html#227338602">(Feb 22 2021 at 21:15)</a>:</h4>
<p>I think this is pretty orthogonal from <span class="user-mention" data-user-id="239881">@Josh Triplett</span> wanting an opt-out; I think that a lint might serve that job (allow-by-default)</p>



<a name="227338707"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/268952-edition%202021/topic/Reverting%20mut%20%2B%20default%20match%20bindings/near/227338707" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/268952-edition-2021/topic/Reverting.20mut.20.2B.20default.20match.20bindings.html#227338707">(Feb 22 2021 at 21:16)</a>:</h4>
<p>In general I feel that binding modes are "incomplete" -- they're a great feature, but they're not done. I'm not 1000% sure what I think would make them feel done. I have a few options.</p>



<a name="227338729"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/268952-edition%202021/topic/Reverting%20mut%20%2B%20default%20match%20bindings/near/227338729" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/268952-edition-2021/topic/Reverting.20mut.20.2B.20default.20match.20bindings.html#227338729">(Feb 22 2021 at 21:16)</a>:</h4>
<p>Yeah, to be clear, I also think it's a good idea to improve match bindings to make them more self-consistent.</p>



<a name="227338961"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/268952-edition%202021/topic/Reverting%20mut%20%2B%20default%20match%20bindings/near/227338961" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/268952-edition-2021/topic/Reverting.20mut.20.2B.20default.20match.20bindings.html#227338961">(Feb 22 2021 at 21:18)</a>:</h4>
<p>I would love to have something that makes me feel a little more in control and a little less like the compiler is aggressively making sense of whatever I throw at it rather than helpfully telling me off, and perhaps type ascription might help with that, but that's orthogonal to fixing issues with match bindings.</p>



<a name="228101471"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/268952-edition%202021/topic/Reverting%20mut%20%2B%20default%20match%20bindings/near/228101471" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> varkor <a href="https://rust-lang.github.io/zulip_archive/stream/268952-edition-2021/topic/Reverting.20mut.20.2B.20default.20match.20bindings.html#228101471">(Feb 28 2021 at 03:28)</a>:</h4>
<p>I think there's too much to discuss to make any change for 2021. But it'd be good to have a discussion about both these aspects (mechanics and more control). I'll try to get around to writing a draft proposal at some point.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>